﻿
using AzukiMap.MapSource.Vector;
using System.Xml.Linq;
using System;
namespace AzukiMap.MapSource
{
    public abstract class VectorSource : MapSource
    {
        protected VectorSourceTypes _vectorType;

        public VectorSourceTypes VectorType
        {
            get { return _vectorType; }
            set { _vectorType = value; }
        }

        public VectorSource(string name, VectorSourceTypes vectorType, int srid, CoordinationUnits coordUnit)
            : base(name, MapSourceTypes.Vector, srid, coordUnit)
        {
            _vectorType = vectorType;
        }

        public override XElement ToXml()
        {
            return ToXml("VectorSource");
        }
            
        public override XElement ToXml(string elementName)
        {
            XElement vectorSourceXml = base.ToXml(elementName);
            vectorSourceXml.Add(
                new XElement("VectorType", _vectorType.ToString())
                );

            return vectorSourceXml;
        }

        public override void Parse(XElement mapSourceXml)
        {
            base.Parse(mapSourceXml);
            _vectorType = (VectorSourceTypes)_xmlCommon.GetEnumElement(mapSourceXml, "VectorType", typeof(VectorSourceTypes));
        }
    }
}
